package com.itpan.Service.Impl;

import com.itpan.Entity.Product;
import com.itpan.Mapper.ProductMapper;
import com.itpan.Service.ProductService;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service

public class ProductServiceImpl implements ProductService {
    @Autowired
    private ProductMapper productMapper;
    @Override
    public List<Product> getAll() {
        return productMapper.findAll();
    }

    @Override
    public List<Product> getAllPage(Integer page, Integer pageSize) {
        RowBounds rowBounds=new RowBounds(page,pageSize);
        return productMapper.findAllPage(rowBounds);
    }

    @Override
    public List<Product> getByName(String Name) {
        Name="%"+Name+"%";
        return productMapper.findByName(Name);
    }

    @Override
    public Product getById(String Id) {
        return productMapper.findById(Id);
    }

    @Override
    public void saveOne(Product product) {
        productMapper.addOne(product);
    }

    @Override
    public void saveAll(List<Product> list) {
        productMapper.addList(list);
    }

    @Override
    public void update(Product product) {
        productMapper.update(product);
    }

    @Override
    public void delete(String Id) {
        productMapper.deleteById(Id);
    }

    @Override
    public List<Product> getbymutil(Product product) {
        return productMapper.getbymutil(product);
    }

    @Override
    public List<Product> getbycid(String id) {
        return productMapper.getbycid(id);
    }


}
